<?php

namespace app\models;
use Yii;

/**
 * This is the model class for table "test".
 *
 * @property int $id 主键自增id
 * @property string|null $name
 * @property int|null $gender
 * @property int $age
 */
class Test extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'test';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['gender', 'age'], 'integer'],
            [['age'], 'required'],
            [['name'], 'string', 'max' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'gender' => 'Gender',
            'age' => 'Age',
        ];
    }
    //添加一条数据
    public function Test_Add($data){
        $user = new Test();
        $user->name = $data['name'];
        $user->age = $data['age'];
        $user->content = $data['content'];
        $res = $user->insert();
        return $res;
    }
}
